package com.simple.mrchip.app;

import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.util.List;
import java.util.zip.Inflater;

public class AttendListViewAdapter extends BaseAdapter {

    private List<Pair<String, String>> mList;
    private LayoutInflater mInflater;
    public  AttendListViewAdapter(LayoutInflater layoutInflater, List<Pair<String, String>> list) {
        mList = list;
        mInflater = layoutInflater;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = mInflater.inflate(R.layout.view_list_item, null);
        Pair<String, String> object = (Pair<String, String>) getItem(position);
        TextView seq = (TextView) view.findViewById(R.id.lbSeq);
        TextView attendTime = (TextView) view.findViewById(R.id.lbTimeWork);
        Button btState = (Button) view.findViewById(R.id.btState);
        seq.setText("No." + (position+1));
        attendTime.setText(object.first);
        if (object.second.toString().equals("True")) {
            btState.setText(R.string.text_state_fine);
            btState.setTextColor(Color.BLACK);
        } else {
            btState.setText(R.string.text_state_warning);
            btState.setTextColor(Color.RED);

        }
        view.setClickable(false);
        return view;
    }
}
